<?php
// +----------------------------------------------------------------------
// | makePHP 
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://makephp.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed BSD.(http://www.make.org/BSD-license.txt)
// +----------------------------------------------------------------------
// | Author: 叁石(sanshi) <sanshi0815@tom.com>
// | Author: 白家昌<baijc2004cn@126.com>
// +----------------------------------------------------------------------

/**     
 * base class   
 * @version		1.0.0
 * @author			sanshi
 */
include_once(dirname(__FILE__)."/MemcacheBase.class.php");
class memcacheSession extends MemcacheBase
{
	function memcacheSession()
	{
		//设置session的有效时间
		$this->maxLife = get_cfg_var('session.gc_maxlifetime') ? get_cfg_var('session.gc_maxlifetime') : 1440;
	}
	function __open($save_path, $session_name)
	{
		$this->memcacheObject();
		return true;
	}
	function __close()
	{
		$this->close();
		return true;
	}
	/**
	 * 读取session
	*/
	function __read($sessionID)
	{
		$data = $this->get($sessionID);
		if(is_array($data))
			$this->update($sessionID,$data,$this->maxLife);
		return $data;
	}
	/**
	 * 写入session
	*/
	function __write($sessionID, $sessionData)
	{
		return $this->set($sessionID,$sessionData,$this->maxLife);
	}
	/**
	 * 注销session
	*/
	function __destroy($sessionID)
	{
		return $this->delete($sessionID);
	}
	/**
	 * 销毁过期session
	*/
	function __gc($sessionID)
	{
		return true;
	}
}
?>